<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="admin.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>

</head>
<body onload="load();">
<div id="wrapper">
<div id="main_box">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span><s:text name="admin.title"/></div>
	<div class="listtit" id="listtit"><p><span><strong><s:text name="admin.list.title"/></strong></span></p></div>
	<s:form action="admin-list" id="search_form">
	<div class="searchbox">
		<table class="searchTable">
			<tbody id="searchTable">
				<tr>
					<td class="text"><label for="search" class="labelKeywords"><s:text name="key.words"/>:</label></td>
					<td class="input" ><div class="txtsearch"><s:textfield name="admin.keyword"  cssClass="txtsearch_i" ></s:textfield></div></td>
					<td><label for="qry_activeStatus"><s:text name="admin.activeStatus"/>: </label></td>
					<td>
						<s:select cssStyle="width:121px" list="isActiveList" class="selectClass" name="admin.active" listKey="dictionaryKey" listValue="dictionaryValue" headerKey="--" headerValue="请选择" />
					</td>
					<td><label for="qry_cmsRole"><s:text name="admin.cmsRole"/>: </label></td>
					<td>
						<s:select list="roleLists" id="admin.role.roleId" name="admin.role.roleId" listKey="roleId" listValue="roleName" class="selectClass" type="text" headerKey="0" headerValue="请选择"></s:select>
					</td>
				</tr>
				<tr>
					<td><label for="qry_startTime"><s:text name="admin.createTimeStart"/>: </label></td>
					<td>
					<input name="admin.createTimeStart"  class="Wdate" id="qry_startTime" readonly="true"  value="<s:property value="%{formatDate(admin.createTimeStart)}"/>"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'qry_endTime\')||\'2030-10-01\'}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})" type="text"/>
					</td>
					<td><label for="qry_endTime"><s:text name="admin.createTimeEnd"/> </label></td>
					<td>
					<input name="admin.createTimeEnd"  class="Wdate" id="qry_endTime" readonly="true"  value="<s:property value="%{formatDate(admin.createTimeEnd)}"/>"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'qry_startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})" type="text"/>
					</td>
					<td >
					</td>
					<td align="center">
						<div class="searchboxrt"><input type="button" value="<s:text name="query"/>" class="btnsearch" id="search_btn"/></div>
					</td>
				</tr>
			</tbody>
		</table>
		
		<div class="clear"></div>
	</div>
	<div class="listoperate">
		<span class="cssa"><input id="top_new_btn" type="button" value="<s:text name="new"/>" class="btnadd"/></span>
		<span>
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="top_anti_btn"/>
			<input type="button" value="<s:text name="admin.passwd"/><s:text name="reset"/>" class="btnlist4" id="top_InitPwd_btn"/>
			<input type="button" value="<s:text name="disable"/>" class="btnlist2" id="top_Disable_btn"/>
			<input type="button" value="<s:text name="enable"/>" class="btnlist2" id="top_Enable_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="top_del_btn"/>
		</span>
	</div>
	<div class="listbox" id="listbox">
		<table class="listgrid" id="listbox">
			<tbody>
				<tr>
					<th><input type="checkbox" name="all" id="totalCheck"/></th>
					<th><s:text name="admin.loginName"/></th>
					<th><s:text name="area"/></th>
					<th><s:text name="admin.cmsRole"/></th>
					<th><s:text name="admin.activeStatus"/></th>
					<th><s:text name="admin.mobile"/></th>
					<th><s:text name="admin.email"/></th>
					<th><s:text name="operate"/></th>
				</tr>
				<s:iterator value="page.result">
				<tr>
					<td><input type="checkbox" name="key" value="<s:property value="adminId"/>"/></td>
					<td><s:property value="loginName"/>(<s:property value="realName"/>)&nbsp;</td>
					<td><s:property value="%{getName(area,'AREA')}"/>&nbsp;</td>
					<td>
						<s:if test="!role.activeStatus"><font color="red"><s:property value="role.roleName"/>&nbsp;</font></s:if>
						<s:else><s:property value="role.roleName"/>&nbsp;</s:else>
					</td>
					<td>
						<s:if test="!activeStatus"><font color="red"><s:property value="%{getName(activeStatus,'IS_ACTIVE')}"/>&nbsp;</font></s:if>
						<s:else><s:property value="%{getName(activeStatus,'IS_ACTIVE')}"/>&nbsp;</s:else>
					</td>
					<td><s:property value="mobile"/>&nbsp;</td>
					<td><s:property value="email"/>&nbsp;</td>
						<td>
							<a href="#this" onclick="edit('<s:property value="adminId"/>')"><s:text name="edit"/></a><tt>|</tt>
							<a href="#this" onclick="disableOrEnable('<s:property value="adminId"/>',<s:if test="activeStatus==1">1</s:if><s:else>2</s:else>);"><s:if test="activeStatus==1"><s:text name="disable"/></s:if><s:else><s:text name="enable"/></s:else></a><tt>|</tt>
							<a href="#this" onclick="initPwd('<s:property value="adminId"/>');"><s:text name="admin.passwd"/><s:text name="reset"/></a><tt>|</tt>
						    <a href="#this" onclick="goDel('<s:property value="adminId"/>')"><s:text name="delete"/></a><tt>|</tt>
						    <a href="#this" onclick="opercode('<s:property value="adminId"/>')"><s:text name="admin.allocate"/></a>
						</td>
				</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>
	<div class="listoperateb h60">
		
		<span class="fl">
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="bottom_anti_btn"/>
			<input type="button" value="<s:text name="admin.passwd"/><s:text name="reset"/>" class="btnlist4" id="bottom_InitPwd_btn"/>
			<input type="button" value="<s:text name="disable"/>" class="btnlist2" id="bottom_Disable_btn"/>
			<input type="button" value="<s:text name="enable"/>" class="btnlist2" id="bottom_Enable_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="bottom_del_btn"/>
		</span>
		<div class="pager fr w550"><z:page numberNav="true" selectPageSize="true" input="true" id="ctrl"/></div>
	</div>
		</s:form>
</div>
</div>
</body>
</html>
<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" defer="defer">
	actionName = "admin";	
	confirmStr = "<s:text name="delete.confirm"/>";
	chiocenothing = "<s:text name="chiocenothing"/>";
	$(function(){
 		$("#top_new_btn").click(goNew);
 		$("#top_del_btn").click(geBatchDelete);
 		$("#bottom_del_btn").click(geBatchDelete);
 		$("#bottom_anti_btn").click(antiSelect);
		$("#search_btn").click(search);
		$("#totalCheck").click(selAll);
		$("#bottom_Enable_btn").click(batchEnable);
		$("#top_Enable_btn").click(batchEnable);
		$("#top_anti_btn").click(antiSelect);
		$("#bottom_Disable_btn").click(batchDisable);
		$("#top_Disable_btn").click(batchDisable);
		$("#bottom_InitPwd_btn").click(batchInitPwd);
		$("#top_InitPwd_btn").click(batchInitPwd);
	});
	
	var g = function(D) {
		if ( D.indexOf(" ") == -1){
			return ( D.substring(0,1) === "#") ? document.getElementById(D.substring(1,D.length)) : document.getElementsByTagName(D);
		}
		else {
			var ary = D.split(" ");
			return g(ary[0]).getElementsByTagName(ary[1]);
		}
	};
	function inputvalue(){
		var d = g("#listbox input"), i = 0, j = d.length, str = "";
	    for ( ; i < j ; i ++ ) {
				str += (d[i].type == "checkbox" && d[i].id != "totalCheck" && d[i].checked == true ) ? d[i].value + "@" : "";
		};	
		return (str.slice(0,-1));
	};
	
	function edit(id){
		document.location.href="${ctx}/system/admin-input.action?admin.adminId="+id+"&orig=edit";
	}
	//初始化密码
	function initPwd(id){
		var myDate=new Date();
		if(confirm('<s:text name="sureInitpwd"/>')){
			$.post("${ctx}/system/admin-initPwd.action?admin.adminId="+id+"&myTime="+myDate,function(data){
				if(data=="ok"){
					alert('<s:text name="doSuccess"/>');
				}else{
					alert('<s:text name="doFail"/>');
				}
			}); 
		}
	}
	//禁用/启用
	function disableOrEnable(id,dn){
		var myDate=new Date();
		var sign="";
		if(dn=="1"){
			sign='<s:text name="sureDisable"/>';
		}else{
			sign='<s:text name="sureEnable"/>';
		}
		if(confirm(sign)){
			document.location.href="${ctx}/system/admin-disableorenable.action?admin.adminId="+id;
		}
	}
	//删除管理员
	function  goDel(id){
		if(confirm('<s:text name="sureDelete"/>')){
			document.location.href="${ctx}/system/admin-delete.action?admin.adminId="+id;
		}
	}
	
	function geBatchDelete(){
		var ids = inputvalue();
		if(!ids){
			return;
		}
		if(confirm('<s:text name="sureDelete"/>')){
			document.location.href="${ctx}/system/admin-delete.action?ids="+ids;
		}
	}

	
	//批量禁用
	function batchDisable(){
		var ids = inputvalue();
		if(!ids){
			return;		
		}
		if(confirm('<s:text name="sureDisable"/>')){
			document.location.href="${ctx}/system/admin-activestatus.action?ids="+ids+"&admin.activeStatus="+false;
		}
	}
	//批量启用
	function batchEnable(){
		var ids = inputvalue();
		if(!ids){
			return;		
		}
		if(confirm('<s:text name="sureEnable"/>')){
			document.location.href="${ctx}/system/admin-activestatus.action?ids="+ids+"&admin.activeStatus="+true;
		}
	}
	
	
	//批量初始化密码
	function batchInitPwd(){
		var ids = inputvalue();
		if(!ids){
			return;		
		}
		var myDate=new Date();
		if(confirm('<s:text name="sureInitpwd"/>')){
			$.post("${ctx}/system/admin-initPwd.action?ids="+ids+"&myTime="+myDate,function(data){
				if(data=="ok"){
					alert('<s:text name="doSuccess"/>');
				}else{
					alert('<s:text name="doFail"/>');
				}		}); 
		}
	}
	
	
	function opercode(id){
		window.open("${ctx}/system/opercode-list.action?objectType=admin&objectId="+id,"newwindow", "height=500, width=800, toolbar =no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
	}
	$(function(){
		if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
			$('#main_box').width($('#main_box').width()-25);
		}
	});
	
	function load(){
		if('<s:property value="info"/>'!=''){
			if('<s:property value="info"/>'=='password update success'){
				alert('<s:text name="initpwdSuccess"/>');
			}
			}
		}
	</script>